<template>
  <div id="app">
    <el-header>
      <h1>
        <router-link to="/">
          <a target="_blank">
            <img :src="titleUrl"><font>Notebook</font></a></router-link>
      </h1>
      <div class="user">
        <a :href="blogUrl" target="_blank">
          <img :src="avatarUrl"></a>
      </div>

      <div class="manage">
        <router-link to="/manage/content">
          <a target="_blank">
            <font><i class="el-icon-edit" />编辑</font></a></router-link>
      </div>

      <div class="divider">
        <el-divider direction="vertical" />
      </div>

      <el-menu
        class="header-menu"
        default-active="1"
        mode="horizontal"
        background-color="#545c64"
        text-color="#ffff"
        active-text-color="#ffd04b"
        @select="selectModules"
      >
        <!-- <el-menu-item index="5">   <i class="el-icon-edit" /></el-menu-item> -->
        <el-menu-item index="1"> 指南</el-menu-item>
        <el-menu-item index="2">文档</el-menu-item>
        <el-menu-item index="3"> 题库</el-menu-item>
        <el-menu-item index="4"> 关于</el-menu-item>
      </el-menu>
    </el-header>
    <el-main>
      <router-view />
    </el-main>
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      blogUrl: 'https://yanglinwei.blog.csdn.net/',
      titleUrl: require('./assets/title.png'),
      avatarUrl: require('./assets/avatar.png')
    }
  },
  methods: {
    selectModules(key, keyPath) {
      switch (key) {
        case '1':
          this.$router.push(`/`)
          break
        case '2':
          this.$router.push(`/document/outline`)
          break
        case '3':
          this.$router.push(`/exercises/chapter`)
          break
        case '4':
          this.$router.push(`/about`)
          break
        case '5':
          this.$router.push(`/manage/content`)
          break
      }
    }
  }
}
</script>

<style>
.el-header {
  height: 80px;
  background-color: #545c64;
  color: #fff;
  top: 0;
  left: 0;
  width: 100%;
  line-height: 80px;
  z-index: 100;
  position: relative;
}
.el-header h1 {
  line-height: 60px;
  margin: 0;
  float: left;
}
.el-header h1 a {
  color: #333;
  text-decoration: none;
  display: block;
}
.el-header h1 a img {
  vertical-align: sub;
}
.el-header h1 a font {
  color: #ffd04b;
  margin-left: 10px;
}
.divider {
  float: right;
  line-height: 60px;

}
.manage {
  float: right;
  line-height: 60px;
  margin-right: 20px;
  font-size: 14px;
  color: #ffbb00;
}
.user {
  float: right;
  line-height: 60px;
  margin-left: 10px;
  font-size: 14px;
  text-align: center;
}

.user img {
  height: 32px;
  width: 32px;
  vertical-align: middle;
  margin-right: 10px;
}

.header-menu {
  float: right;
  height: 100%;
  line-height: 80px;
  background: transparent;
  padding: 0;
  margin: 0;
}

.el-main {
  padding: 0px;
  color: #333;
  text-align: center;
  min-width: 100%;
  position: absolute;
  top: 60px;
  bottom: 0px;
  left: 0px;
}
</style>
